/**
 * user edit
 */
let systemType="";
let form,layer,tableSelect,$;
let loginU={};
layui.use(['form', 'tableSelect'], function () {
    form = layui.form,
    layer = layui.layer,
    tableSelect = layui.tableSelect,
    $ = layui.jquery;

    let u=localStorage.getItem("ADMIN_LOGIN");
    if(u==undefined){layer.msg('请登录', {icon: 1, time: 500},function () {window.location = 'page/login.html';});}else{loginU=decryptLocalStorage(u);}
    let viewData=undefined;
    loadData();
    function loadData()
    {
        request.list("movieServer",{token:loginU.token},function(result){
            if(result.code==0){
                let data=result.data;
                viewData=data[0];

                if(data.length>0){
                    $("#shoreUrl").val(viewData.shoreUrl);
                    $("#serverUrl").val(viewData.serverUrl);
                    $("#remark").val(viewData.remark);
                    $("#sonicWallName").val(viewData.sonicWallName);
                    $("#sonicWallIp").val(viewData.sonicWallIp);
                    $("#sonicWallPort").val(viewData.sonicWallPort);
                    $("#sonicWallUserName").val(viewData.sonicWallUserName);
                    $("#sonicWallPassword").val(viewData.sonicWallPassword);
                }
            }
        })
    }

});

function testFun(apiNum)
{
    if(apiNum==null || apiNum==undefined){
        layer.msg('您的参数错误', {
            icon: 2,
            time: 2000
        });
        return;
    }
    let  requestData=$("#params"+apiNum).val();
    let paramsMap={token:loginU.token,apiNum:apiNum,requestData:requestData};
    let loadingWin=layer.load(2, {shade: [0.5, '#fff']});
    console.log(JSON.stringify(paramsMap));
    request.otherPostMethodRequestBody("ystapi","apiTest",JSON.stringify(paramsMap),function(result){
        if (loadingWin != undefined) {
            layer.close(loadingWin);
        }
        if(result.code==0){
            let data=result.data;
            console.log(data);
            $("#result"+apiNum).val(data);
        }else{
            console.log(result.msg);
            layer.msg(result.msg || '保存失败', {
                icon: 2,
                time: 2000
            });
        }
    },function(err){
        if (loadingWin != undefined) {
            layer.close(loadingWin);
        }
        layer.msg(err || '请求失败', {
            icon: 2,
            time: 2000
        });
    });
}